package cn.school.attendance.dormitory.dao;

import cn.school.attendance.dormitory.entity.DormitoryAttendanceDo;
import cn.school.attendance.dormitory.pojo.AttendanceDto;
import cn.school.attendance.dormitory.pojo.QueryParam;
import cn.school.attendance.dormitory.vo.StudentAttendanceVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @className: DormitoryAttendanceMapper
 * @author: Alex
 * @date: 2023/4/7
 **/
@Mapper
public interface DormitoryAttendanceMapper extends BaseMapper<DormitoryAttendanceDo> {


	@Select("select * from t_dormitory_attendance where location_id=#{locationId} and create_time between #{createTime} and #{modifyTime}")
	List<DormitoryAttendanceDo> getListByLocationId(@Param("id") Long id, @Param("createTime") Date createTime, @Param("modifyTime") Date modifyTime);

	//	 ================================ new attendance dao =========================================

	void insertBatch(@Param("attendanceDoList") List<DormitoryAttendanceDo> attendanceDoList);

	void updateBatch(List<DormitoryAttendanceDo> attendanceList);

	List<Long> getListByAttendanceDate(@Param("date")String date);

	List<AttendanceDto> getAttendanceStatsByDay(@Param("queryParam") QueryParam queryParam);

	List<StudentAttendanceVO> getRoomAttendanceDetails(@Param("tenantId") String tenantId,@Param("bedRoomId") Long bedRoomId,@Param("attendanceDate") String attendanceDate);

    List<StudentAttendanceVO> getStudentAttendanceList(@Param("attendanceDate") String attendanceDate,
													@Param("levelName") String levelName,
													@Param("tenantId") String tenantId,
													@Param("status") String status,
													@Param("startNum") Integer startNum,
													@Param("pageSize") Integer pageSize);

	int getStudentAttendanceListCount(@Param("attendanceDate") String attendanceDate,
								   @Param("levelName") String levelName,
								   @Param("tenantId") String tenantId,
								   @Param("status") String status);

	/**
	 * 根据日期查询学生考勤数据
	 * @param format
	 * @return
	 */
	List<AttendanceDto> getAllStuAttendanceDate(String format);

	//查询未归寝学生信息
	List<StudentAttendanceVO> getAllAbsenceStuList(@Param("attendanceDate") String today,@Param("tenantIds") List<String> tenantIds);

	List<StudentAttendanceVO> getAbsenceStudentAndTeacherOpenIdList(@Param("nowDate") String nowDate, @Param("tenantId") String tenantId);

}
